<template>
  <div class="rights">
    <!-- 面包屑导航 -->
    <div>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item><a href="/">权限管理</a></el-breadcrumb-item>
        <el-breadcrumb-item>权限列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- 表格 -->
    <div>
      <el-table
        ref="singleTable"
        :data="rolesList"
        v-loading="loading"
        border
        highlight-current-row
        style="width: 100%">
        <el-table-column
          type="index"
          width="50">
        </el-table-column>
        <el-table-column
          property="authName"
          label="权限名称">
        </el-table-column>
        <el-table-column
          property="path"
          label="路径">
        </el-table-column>
        <el-table-column
          label="层级">
          <template slot-scope="scope">
            <span>
              <el-tag>{{scope.row.level | filtersname}}</el-tag>
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { RightsData } from '@/api'
export default {
  data () {
    return {
      rolesList: [],
      loading: true
    }
  },
  mounted () {
    RightsData('list')
      .then(res => {
        // console.log(res)
        if (res.meta.status === 200) {
          this.rolesList = res.data
          this.loading = false
        }
      })
  },
  filters: {
    filtersname (val) {
      // console.log(val)
      if (val === '0') {
        return '一级'
      } else if (val === '1') {
        return '二级'
      } else if (val === '2') {
        return '三级'
      } else {
        return 'error'
      }
    }
  }
}
</script>

<style>

</style>
